<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UploadController extends Controller
{
    public function upload(Request $request){
		$file = $request->file('file');
		//判断当前文件是否合法
		if ($file->isValid()){
			$path = $file->store(date('ymd'),'upload');
			//上传完成之后,需要按照手册中的方式给固定的返回值
			return ['file' => asset('/uploadImages/' . $path), 'code' => 0];
		}
	}
	public function bianjiqiUpload(Request $request){
		//获取前台请求过来的数据
		$file = $request->file('file');
		if ($file->isValid()){
			$path = $file->store(date('ymd'),'upload');
			//上传完毕,应该按照手册给对应的返回值
			return [
				"success"   => true,
				"msg"       => "图片上传成功",
				"file_path" => asset('/uploadImages/' . $path)//文件地址
			];
		}
	}
}
